t = codesters.Teacher()
keys = t.find_block('def')
handlers = t.find_text('event_key')
try:
tval1 = keys[0][1]
tval2 = t.get_indent_at_line(keys[0][0])
except:
tval1 = "DNE"
tval2 = "DNE"
try:
tval3 = keys[1][1]
tval4 = t.get_indent_at_line(keys[1][0])
except:
tval3= "DNE"
tval4 = "DNE"
try:
tval5 = handlers[0][1].replace(' ', '')
tval6 = t.get_indent_at_line(handlers[0][0])
except:
tval5 = "DNE"
tval6 = "DNE"
try:
tval7 = handlers[1][1].replace(' ', '')
tval8 = t.get_indent_at_line(handlers[1][0])
except:
tval7 = "DNE"
tval8 = "DNE"
t1 = TestObjective()
t1.add_success(('left_key()' in tval1 or 'left_key()' in tval3) and tval2 == 0, "Great job!")
t1.add_failure(tval1 == "DNE", "Did you add a Left Key event and a Right Key event?")
t1.add_failure('left_key' not in tval1 and 'left_key' not in tval3, "Did you add a Left Key event?")
t1.add_failure(tval2 > 0, "Oops! Make sure your first line of your Key Event is not indented!")
t2 = TestObjective()
t2.add_success(('right_key()' in tval1 or 'right_key()' in tval3) and tval4 == 0, "Great job!")
t2.add_failure(tval3 == "DNE", "Did you add a Left Key event and a Right Key event?")
t2.add_failure('right_key' not in tval1 and 'right_key' not in tval3, "Did you add a Right Key event?")
t2.add_failure(tval4 > 0, "Oops! Make sure your first line of your Key Event is not indented!")
t3 = TestObjective()
t3.add_success(('"left",left_key' in tval5 or '"left",left_key' in tval7) and tval6 == 0, "Great job!")
t3.add_failure(tval5 == "DNE", "Oops! Did you delete the last line of your first Key Event?")
t3.add_failure('"left",left_key' not in tval5 and '"left",left_key' not in tval7, "Did you erase the last line of your Left Key event?")
t3.add_failure(tval6 > 0, "Oops! Make sure the last line of your event is not indented!")
t4 = TestObjective()
t4.add_success(('"right",right_key' in tval5 or '"right",right_key' in tval7) and tval8 == 0, "Great job!")
t4.add_failure(tval7 == "DNE", "Oops! Did you delete the last line of your second Key Event?")
t4.add_failure('"right",right_key' not in tval5 and '"right",right_key' not in tval7, "Did you erase the last line of your Right Key event?")
t4.add_failure(tval8 > 0, "Oops! Make sure the last line of your event is not indented!")
#print tval5, tval6
#print tval7, tval8
tester = TestManager()
tester.add_test_list([t1, t2, t3, t4])
tester.run_tests()
tester.display_first_feedback()
Are you already running a Codesters project in another tab or window?
Micro:bit can only connect to one web page at a time.
Try stopping other Codesters projects or closing
other tabs or windows that may be using your Micro:bit.
If that doesn't fix the problem try disconnecting your Micro:bit,
reloading this page, and reconnecting your Micro:bit.